package com.audaque.springboot.foshanupload.core.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @author zgb
 * @desc ...
 * @date 2023-07-09 19:43:39
 */
@Component
@Slf4j
public class BeanPostProcessorListener implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        //log.debug("postProcessBeforeInitialization 在初始化方法前执行");
        log(bean, beanName);
        //配合instance  of 做bean加工
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        //log.debug("postProcessAfterInitialization 在初始化方法后执行");
        //log(bean, beanName);
        //配合instance  of 做bean加工
        return bean;
    }


    private void log(Object bean, String beanName) {
        //log.debug("bean:" + bean);
        //log.debug("beanName:" + beanName);
        Class<?> aClass = bean.getClass();
        String className = aClass.getName();
        //log.debug("className:" + className);
    }


}
